/**
 * 手动访问和传参
 */

var routes = [
    {
        path: "/",
        component: {
            template :`
            <div>
                <h1>首页</h1>
            </div>
            `
        }
    },
    {
        path: "/user/:name",
        name: "user",
        component: {
            template :`
            <div>
                <h1>姓名：{{$route.params.name}}</h1>
                <h2>年龄：{{$route.query.age}} 岁</h2>
            </div>
           `
        },
    },
    {
        path: "/about",
        component: {
            template :`
            <div>
                <h1>关于我</h1>
            </div>
           `
        },

    },
    
]
var vueRouter = new VueRouter({
    routes : routes
})

var app = new Vue({
    el : "#app",
    router : vueRouter,
    methods: {
        onClick: function(){
            setTimeout(function(){
                console.log(this)
                this.vueRouter.push('/about')
                setTimeout(function(){
                    console.log(this)
                    this.vueRouter.push({
                        path: "/user/王花花"
                    })
                    setTimeout(function(){
                        console.log(this)
                        this.vueRouter.push({
                            name: 'user',
                            params : {
                                name: "李栓蛋"
                            }
                        })
                    },2000)
                },2000)
            },2000)
        }
    }
})